/*
 * @Version: 0.0.1
 * @Author: ider
 * @Date: 2021-05-14 18:43:05
 * @LastEditors: ider
 * @LastEditTime: 2021-05-21 18:49:45
 * @Description:
 */

package config

import (
	"context"

	log "github.com/sirupsen/logrus"

	"github.com/joho/godotenv"
	"github.com/sethvargo/go-envconfig"
)

type ProjectConfig struct {
	Version            string `env:"VERSION,required"`
	ArticleXmlFilePath string `env:"ARTICLE_XML_FILE_PATH"`
	MongoUri           string `env:"MONGO_URI,default=mongodb://r730xd-2.lmd.wuzhen.ai:27017"`
	AmqpUri            string `env:"AMQP_URI,default=amqp://rabbitmq:rabbitmq@r730xd-1.lmd.wuzhen.ai:5672/"`
	HttpProxy          string `env:"HTTP_PROXY"`
	// 历史下载的文件夹
	HistoryDumpFileFolder string `env:"HISTORY_DUMP_FILD_FOLDER,required"`
	// 历史下载的version, 用作数据库唯一号
	HistoryDumpVersion string `env:"HISTORY_DUMP_VERSION,required"`
}

var Env ProjectConfig

func init() {
	godotenv.Load()
	ctx := context.Background()
	if err := envconfig.Process(ctx, &Env); err != nil {
		log.Fatal(err)
	}

	log.Info("Current code version:", Env.Version)

}
